package com.itheima.Demo01.demo02;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //创建类（参数）对象
        MyCallable M = new MyCallable();
        //FutureTask包装参数对象（只能包装 带有Callable 或 Runnable 的对象）
        FutureTask<String> ft = new FutureTask<String>(M);
        //创建线程对象
        Thread T1 = new Thread(ft);
        //开启线程
        T1.start();
        //创建Callable的返回值对象
        String s = ft.get();
        //打印
        System.out.println(s);

    }
}
